package com.zerosky.crm.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class DateUtil {
	public static void main(String[] args) {
		Map<String,Object> map = new HashMap<>();
		map.put("date", "1");
		map.put("date", "2");
	}
		public static String getThisMonth(){
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
			Date date = new Date();
			return sdf.format(date);
		}
		public static String getThisYear(){
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
			Date date = new Date();
			return sdf.format(date);
		}
		public static String getLastMonth(){
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
			Date date = new Date();
			Calendar cal = Calendar.getInstance();
	        cal.setTime(date);
	        cal.add(Calendar.MONTH, -1);
			return sdf.format(cal.getTime());
		}
		public static String getMonthOfThisYear(String month){
			Integer m = Integer.parseInt(month);
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
			Date date = new Date();
			String  year = sdf.format(date);
			if(m<10){
				 month = "0"+m;
			}
			return year+"-"+month;
		}
}
